from flask_redis import FlaskRedis


class config:
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    REDIS_PASSWORD = None
    REDIS_DB = 0


# 创建一个用于存储 Redis 客户端的变量
_redis_client = None


def init_redis_client(app):
    global _redis_client
    if not _redis_client:
        _redis_client = FlaskRedis(app)
        _redis_client.init_app(app)
    return _redis_client


def get_redis_client():
    if not _redis_client:
        raise Exception("Redis client is not initialized. Ensure it's initialized before using.")
    return _redis_client
